<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/11/8 10:07
 */

namespace App\Transformers\Api;

use App\Models\Patient;
use App\User;
use League\Fractal\TransformerAbstract;

class TokenTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['doctor', 'patient'];

    public function transform(User $user)
    {
        return ['token' => $user->api_token, 'rong_token' => $user->rong_token];
    }

    public function includePatient(Patient $patient)
    {
        return $this->item($patient, (new PatientTransformer())->setDefaultIncludes(['physique']));
    }


    public function includeDoctor(User $user)
    {
        return $this->item($user, (new DoctorTransformer())->setDefaultIncludes(['physique']));
    }
}